package io.sage.modules.exam.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @author xujh
 *
 */
public enum QuestionGradeEnum {
    HARD(3, "困难"),
    NORMAL(2, "中等"),
    EASY(1, "简单");

    private Integer code;
    private String message;
    
    
    /**
     * 根据code获取message
     * @param code
     * @return
     */
    public static String getMessage(Integer code){
        for (QuestionGradeEnum examEnum : QuestionGradeEnum.values()){
            if (code.equals(examEnum.getCode()) || code == examEnum.getCode()){
                return examEnum.getMessage();
            }
        }
        return null;
    }
    
    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
        QuestionGradeEnum[] values = QuestionGradeEnum.values();
        for (QuestionGradeEnum questionGradeEnum : values) {
            HashMap<String, Object> hashMap = new HashMap<String, Object>();
            hashMap.put("code", questionGradeEnum.getCode());
            hashMap.put("message", questionGradeEnum.getMessage());
            returnList.add(hashMap);
        }
        return returnList;
    }
    
	private QuestionGradeEnum(Integer code, String message) {
		this.code = code;
		this.message = message;
	}
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}

}
